package com.cenluan.admin;

import com.cenluan.common.Const;
import com.cenluan.user.User;
import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;

/**
 * 管理员角色拦截器
 * 
 * @author peak
 * 
 */
public class AdminInterceptor implements Interceptor {

	public void intercept(ActionInvocation ai) {
		Controller c = ai.getController();
		User user = c.getSessionAttr(Const.SESSION_USER);
		if (!User.ROLE_ADMIN.equals(user.getStr("role"))) {
			c.renderError(403);
			return;
		}
		ai.invoke();
	}

}
